<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>查看已选课程</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
    <script src="./layui/layui.js"></script>
    <script src="./js/jquery-3.6.0.js"></script>
</head>
<body>
<div style="padding: 20px;">
    <table class="layui-hide" id="viewCourseTable" lay-filter="viewCourseTable"></table>
</div>

<script>
    layui.use(['table', 'layer'], function(){
        var table = layui.table;
        var $ = layui.jquery;

        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
            }
            return(false);
        }

        var studentId = getQueryVariable('studentId');

        table.render({
            elem: '#viewCourseTable',
            url: '/api/student/' + studentId + '/courses',
            cols: [[
                {field: 'courseId', title: '课程ID'},
                {field: 'regularScore', title: '平时成绩'},
                {field: 'labScore', title: '实验成绩'},
                {field: 'examScore', title: '考试成绩'},
                {field: 'finalScore', title: '最终成绩'},
                {field: 'creditsEarned', title: '所得学分'}
            ]]
        });
    });
</script>
</body>
</html>
